package com.atguigu.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : hzyao
 * @date : 17:56 2021/3/11
 */
@Configuration
public class GulimallElasticsearchConfig {

//    @Bean
//    public void esrestClient(){
//        RestHighLevelClient client = new RestHighLevelClient(
//                RestClient.builder(
//                        new HttpHost("127.0.0.1",9200,"http")
//
//                ));
//        return;
//    }
    @Bean
    public  RestHighLevelClient restHighLevelClient(){
        RestClientBuilder builder = null;
        builder = RestClient.builder(new HttpHost("127.0.0.1",9200,"http"));
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }
}
